<template>
  <view>
    <u-radio-group v-model="checkValue" :placement="placement" @change="change">
      <u-radio
        v-for="(item, index) in list" :key="index" :label="item[props.label]" :name="item[props.value]"
        style="margin-left: 15px" />
    </u-radio-group>
  </view>
</template>

<script>
export default {
  name: 'RadioButton',
  props: {
    modelValue: {
      type: String,
      default: ''
    },
    list: {
      type: Array,
      default () {
        return []
      }
    },
    placement: {
      type: String,
      default: 'row'
    },
    props: {
      type: Object,
      default () {
        return {
          value: 'value',
          label: 'label'
        }
      }
    }
  },
  emits: ['update:modelValue'],
  data() {
    return {
      checkValue: undefined
    }
  },
  watch: {
    modelValue: {
      immediate: true,
      handler(val) {
        this.checkValue = undefined
        if (this.isNull(val)) {
          return
        }
        this.checkValue = val
      }
    }
  },
  methods: {
    change(val) {
      this.$emit('update:modelValue', val)
    }

  }

}
</script>

<style scoped>

</style>
